<?php

namespace app\admin\controller;

use app\common\controller\Backend;
use think\Config;
use think\Db;

/**
 * 控制台
 *
 * @icon fa fa-dashboard
 * @remark 用于展示当前系统中的统计数据、统计报表及重要实时数据
 */
class Tdsum extends Backend
{

    /**
     * 查看
     */
    public function index()
    {
        $seventtime = \fast\Date::unixtime('day', -7);
        $paylist = $createlist = [];
        for ($i = 0; $i < 7; $i++)
        {
            $day = date("Y-m-d", $seventtime + ($i * 86400));
            $createlist[$day] = mt_rand(20, 200);
            $paylist[$day] = mt_rand(1, mt_rand(1, $createlist[$day]));
        }
        $hooks = config('addons.hooks');
        $uploadmode = isset($hooks['upload_config_init']) && $hooks['upload_config_init'] ? implode(',', $hooks['upload_config_init']) : 'local';
        $addonComposerCfg = ROOT_PATH . '/vendor/karsonzhang/fastadmin-addons/composer.json';
        Config::parse($addonComposerCfg, "json", "composer");
        $config = Config::get("composer");
        $addonVersion = isset($config['version']) ? $config['version'] : __('Unknown');
      
		$time = time();
		//$times=date("y-m-d",$time) //2010-08-29
		$showtime=date("Y-m-d");
		$data = Db::name('tdsum')->where('querydate', $showtime)->find();//->select();
		
		
		$list = Db::name('tdsum')
			->where('createtime', 3)
			->field('createtime')
			->order('id', 'desc')
			->limit(2)
			->select();
		//dump($list);
		
		$resultdemo = Db::query("select normals,faults,createdate from fa_tdsum where createdate between '2018-06-25' and '2018-06-27'");
		//dump($resultdemo);
		
		$this->assign('result', $data);
		$this->assignconfig('demo', $resultdemo);
		//$this->assignconfig('demos', $list);
		
		$this->view->assign([
			'Equips'        => 300,
            'OffEquips'        => 300,
            'Normals'       => 219390,
            'Faults'       => 32143,
            'Fixfaults' => 174800,
            // 'todayuserlogin'   => 321,
            // 'todayusersignup'  => 430,
            // 'todayorder'       => 2324,
            // 'unsettleorder'    => 132,
            // 'sevendnu'         => '80%',
            // 'sevendau'         => '32%',
            // 'paylist'          => $paylist,
            // 'createlist'       => $createlist,
            // 'addonversion'       => $addonVersion,
            // 'uploadmode'       => $uploadmode
        ]);

        return $this->view->fetch();
    }
	
	
}



  
